Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support importing local workflow templates #208

Merged
merged 6 commits into from
Jul 10, 2024

Conversation

ohltyler
Copy link
Member

@ohltyler ohltyler commented Jul 10, 2024

Description

This PR adds support for importing locally saved workflow templates in JSON or YAML format. A new button is available on the base workflows page, for both the workflows list and the new workflow tabs. When clicked, opens up a modal where users can drag-and-drop or import a template from their local filesystem. The modal will validated and prevent or allow importing, depending on 3 different states:

  1. Valid UI template (containing the required workflow fields, + containing ui_metadata field). No warnings, and users can import. Note if this is manually done / misconfigured this may still fail; it is up to the user to not corrupt the values within ui_metadata.
  2. Valid template (containing the required workflow fields, but not containing ui_metadata). Warns that the workflow can be imported, but may not be visible from the editor etc. since there is no ui metadata to parse.
  3. Invalid template (doesn't contain the required workflow fields, isn't a JSON or YAML file, isn't a parse-able JSON or YAML file, etc.). Tells user the workflow is invalid, blocks any import.

When a user clicks "Import", the plugin attempts to create that workflow on the selected cluster, and is then viewable the same way as any other workflow. Any failures are propagated in a toast message with details, no different than if they were to run the create workflow API directly with the contents of the file.

Demo video showing the 3 different states, and successful importing into the cluster via the modal:

screen-capture.webm

Testing:

  • JSON template pulled via export step can be imported and load everything correctly
  • YAML templated pulled via export step can be imported and load everything correctly
  • non-JSON/non-YAML files are rejected
  • format issues with JSON or YAML files are rejected
  • workflows with no ui_metadata show correct state
  • workflows with valid ui_metadata show correct state

Other minor changes:

  • improves spacing on invalid UI workflow state
  • helper functions for determining the validity of a workflow template
  • moves the create workflow button into a button on the right-hand side on the workflows list page
  • minor wording and format updates to headers on the workflows page

Issues Resolved

Makes progress on #66

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@ohltyler ohltyler marked this pull request as ready for review July 10, 2024 18:19
@ohltyler ohltyler merged commit ae53f00 into opensearch-project:main Jul 10, 2024
6 checks passed
@ohltyler ohltyler deleted the import-flow branch July 10, 2024 21:26
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jul 10, 2024
Signed-off-by: Tyler Ohlsen <[email protected]>
(cherry picked from commit ae53f00)
ohltyler added a commit that referenced this pull request Jul 10, 2024
Signed-off-by: Tyler Ohlsen <[email protected]>
(cherry picked from commit ae53f00)

Co-authored-by: Tyler Ohlsen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants